<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ include file="/static/include/taglib.jsp" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>后台管理--用户编辑</title>
    <link href="${ctxStatic}/ligeruilib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css">
    <link href="${ctxStatic}/layui/css/layui.css" rel="stylesheet"/>
    <link href="${ctxStatic}/css/kpiuitanchu.css" rel="stylesheet"/>
    <script src="${ctxStatic}/js/jquery-1.8.3.min.js?v=2.0" type="text/javascript"></script>
    <script src="${ctxStatic}/layui/layui.all.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/core/base.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="${ctxStatic}/ligeruilib/ligerUI/js/plugins/ligerComboBox.js" type="text/javascript"></script>

    <script>
        $(function () {
            var orgdata = null;
            var groupid = $("#hidgroup").val();
            $.ajax({
                url: "../common/get_org_list?orgtype=1",
                type: "get",
                success: function (data) {
                    //orgdata=data;
                    orgdata = eval('(' + data + ')');
                    if (groupid != '' && groupid != null) {
                        var newData = new Array();
                        for (i = 0; i < orgdata.length; i++) {
                            if (orgdata[i].orgid == groupid) {
                                newData.push(orgdata[i]);
                            }
                        }
                        liger.get("group").setData(newData);
                        liger.get("group").setValue(groupid);
                    }

                }
            })

            var szdw = $("#hidszdw").val();
            if (szdw != '' && szdw != null) {
                $("#szdw").ligerComboBox({
                    valueField: 'orgid',
                    textField: 'orgname',
                    selectBoxWidth: 278,
                    selectBoxHeight: 200,
                    treeLeafOnly: true,
                    valueFieldID: "hid",
                    value: $("#hidszdw").val(),
                    initIsTriggerEvent: false,
                    tree: {
                        url: '../common/get_org_list?orgtype=0',
                        checkbox: false,
                        nodeWidth: 177,
                        ajaxType: 'get',
                        idFieldName: 'orgid',
                        textFieldName: "orgname",
                        idField: "orgid",
                        parentIDField: "orgparentid"
                    },
                    onSelected: function (orgid, orgname) {// id为空值，name为选择的值
                        $("#hidszdw").val(orgid);

                        var newData = new Array();
                        for (i = 0; i < orgdata.length; i++) {
                            if (orgdata[i].orgparentid == orgid) {
                                newData.push(orgdata[i]);
                            }
                        }
                        liger.get("group").setData(newData);

                    },
                    width: 280
                });
            }
            else {
                $("#szdw").ligerComboBox({
                    valueField: 'orgid',
                    textField: 'orgname',
                    selectBoxWidth: 278,
                    selectBoxHeight: 200,
                    treeLeafOnly: true,
                    valueFieldID: "hid",
                    initIsTriggerEvent: false,
                    tree: {
                        url: '../common/get_org_list?orgtype=0',
                        checkbox: false,
                        nodeWidth: 177,
                        ajaxType: 'get',
                        idFieldName: 'orgid',
                        textFieldName: "orgname",
                        idField: "orgid",
                        parentIDField: "orgparentid"
                    },
                    onSelected: function (orgid, orgname) {// id为空值，name为选择的值
                        $("#hidszdw").val(orgid);

                        var newData = new Array();
                        for (i = 0; i < orgdata.length; i++) {
                            if (orgdata[i].orgparentid == orgid) {
                                newData.push(orgdata[i]);
                            }
                        }
                        liger.get("group").setData(newData);

                    },
                    width: 280
                });
            }


            var rsgxszdw = $("#hidrsgxszdw").val();
            if (rsgxszdw != '' && rsgxszdw != null) {
                $("#rsgxszdw").ligerComboBox({
                    valueField: 'orgid',
                    textField: 'orgname',
                    selectBoxWidth: 278,
                    selectBoxHeight: 200,
                    treeLeafOnly: true,
                    valueFieldID: "hid",
                    value: $("#hidrsgxszdw").val(),
                    initIsTriggerEvent: false,
                    tree: {
                        url: '../common/get_org_list?orgtype=0',
                        checkbox: false,
                        nodeWidth: 177,
                        ajaxType: 'get',
                        idFieldName: 'orgid',
                        textFieldName: "orgname",
                        idField: "orgid",
                        parentIDField: "orgparentid"
                    },
                    onSelected: function (orgid, orgname) {// id为空值，name为选择的值
                        $("#hidrsgxszdw").val(orgid);
                    },
                    width: 280
                });
            }
            else {
                $("#rsgxszdw").ligerComboBox({
                    valueField: 'orgid',
                    textField: 'orgname',
                    selectBoxWidth: 278,
                    selectBoxHeight: 200,
                    treeLeafOnly: true,
                    valueFieldID: "hid",
                    initIsTriggerEvent: false,
                    tree: {
                        url: '../common/get_org_list?orgtype=0',
                        checkbox: false,
                        nodeWidth: 177,
                        ajaxType: 'get',
                        idFieldName: 'orgid',
                        textFieldName: "orgname",
                        idField: "orgid",
                        parentIDField: "orgparentid"
                    },
                    onSelected: function (orgid, orgname) {// id为空值，name为选择的值
                        $("#hidrsgxszdw").val(orgid);


                    },
                    width: 280
                });
            }


            $("#group").ligerComboBox({
                data: null,
                valueField: 'orgid',
                textField: 'orgname',
                selectBoxWidth: 278,
                selectBoxHeight: 200,
                autocomplete: true,
                width: 280,
                onSelected: function (orgid, orgname) {//id为空值，name为选择的值
                    $("#hidgroup").val(orgid);
                },
            })


        })

        function InitGroup(orgid) {
            $("#group").ligerComboBox(
                {
                    url: '../common/get_org_list_byorgid?orgid=' + orgid,
                    valueField: 'orgid',
                    textField: 'orgname',
                    selectBoxWidth: 280,
                    selectBoxHeight: 200,
                    autocomplete: true,
                    keySupport: true,
                    valueFieldID: "hid",
                    onSelected: function (orgid, orgname) {//id为空值，name为选择的值
                        $("#hidgroup").val(orgid);
                    },
                    width: 280
                }
            );
        }


        function InitGroupTree(orgid) {
            $("#group").ligerComboBox({
                valueField: 'orgid',
                textField: 'orgname',
                selectBoxWidth: 280,
                selectBoxHeight: 200,
                treeLeafOnly: false,
                valueFieldID: "hidorgtype",

                tree: {
                    url: '../common/get_org_list?orgtype=1',
                    checkbox: false,
                    nodeWidth: 167,
                    ajaxType: 'get',
                    idFieldName: 'orgid',
                    textFieldName: "orgname",
                    idField: "orgid",
                    parentIDField: "orgparentid",
                    selectable: function (data) {
                        if (data.orgtype == 0) {
                            return false;
                        }
                        else {
                            return true;
                        }
                    },
                    onBeforeSelect: function (data) {
                        if (data.data.orgtype == 0) {
                            return false;
                        }
                        else {
                            return true;
                        }
                    }
                },
                onSelected: function (orgid, orgname) {// id为空值，name为选择的值
                    $("#hidgroup").val(orgid);
                },
                //onBeforeSelect:function(orgid,orgname){
                // return false;
                //},
                width: 280
            });
        }

    </script>
</head>
<body>
<div class="tanchucontent">
    <form class="layui-form" id="formedit" name="formedit" action="add_user" method="post"
          target="d41d8cd98f00b204e9800998ecf8427e">
        <iframe name="d41d8cd98f00b204e9800998ecf8427e" src="about:blank" style="display:none;"></iframe>

        <table style="width:95%">
            <tr>
                <td class="td_right" style="width:130px">用户名：</td>
                <td>
                    <c:if test="${entity.username!= null && entity.username!=null }">
                        <input type="text" id="username" disabled="disabled" name="username" lay-verify="required"
                               autocomplete="off" class="layui-input" value="${entity.username}">
                    </c:if>
                    <c:if test="${entity.username== null || entity.username==null }">
                        <input type="text" id="username" name="username" lay-verify="required" autocomplete="off"
                               class="layui-input" value="${entity.username}">
                    </c:if>

                </td>
                <td class="td_right">姓名：</td>
                <td>
                    <input type="text" name="realname" lay-verify="required" autocomplete="off" class="layui-input"
                           value="${entity.realname}">
                </td>
            </tr>
            <tr>
                <td class="td_right">角色：</td>
                <td style="width:280px">
                    <select name="roleid" lay-verify="required">
                        <c:forEach var="item" items="${lstrole}">
                            <c:if test="${entity.roleid == item.roleid}">
                                <option selected="selected" value="${item.roleid}">${item.rolename}</option>
                            </c:if>
                            <c:if test="${entity.roleid != item.roleid}">
                                <option value="${item.roleid}">${item.rolename}</option>
                            </c:if>
                        </c:forEach>
                    </select>
                </td>
                <td class="td_right">手机：</td>
                <td>
                    <input type="text" name="phone" autocomplete="off" class="layui-input" value="${entity.phone}">
                </td>
            </tr>
            <tr>
                <td class="td_right">实际工作单位：</td>
                <td>
                    <input type="text" id="szdw" lay-verify="required" style="padding-left:10px;" class="layui-input">
                    <input type="hidden" id="hidszdw" name="szdw" value="${entity.szdw}">
                </td>
                <td class="td_right">人事关系所在单位：</td>
                <td>
                    <input type="text" id="rsgxszdw" lay-verify="required" style="padding-left:10px;"
                           class="layui-input">
                    <input type="hidden" id="hidrsgxszdw" name="rsgxszdw" value="${entity.rsgxszdw}">
                </td>
            </tr>
            <tr>

                <td class="td_right">所在分组：</td>
                <td>
                    <input type="text" id="group" style="padding-left:10px;" class="layui-input">
                    <input type="hidden" id="hidgroup" name="groupid" value="${entity.groupid}">
                </td>
                <td class="td_right">个人身份：</td>
                <td>
                    <input type="text" name="grsf" lay-verify="required" autocomplete="off" class="layui-input"
                           value="${entity.grsf}">
                </td>
            </tr>
            <tr>
                <td class="td_right">领导职务：</td>
                <td>
                    <input type="text" name="ldzw" autocomplete="off" class="layui-input" value="${entity.ldzw}">
                </td>
                <td class="td_right">非领导职务：</td>
                <td>
                    <input type="text" name="fldzw" autocomplete="off" class="layui-input" value="${entity.fldzw}">
                </td>
            </tr>
            <tr>
                <td class="td_right">从事工作：</td>
                <td>
                    <input type="text" name="csgz" autocomplete="off" class="layui-input" value="${entity.csgz}">
                </td>
                <td class="td_right">警衔信息：</td>
                <td>
                    <input type="text" name="jxxx" lay-verify="required" autocomplete="off" class="layui-input"
                           value="${entity.jxxx}">
                </td>
            </tr>
            <tr>
                <td class="td_right">民族：</td>
                <td>
                    <select name="nation" lay-verify="required">
                        <c:forEach var="item" items="${mzlst}">
                            <c:if test="${item.codename == entity.nation}">
                                <option selected="selected" value="${item.codename}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codename != entity.nation}">
                                <option value="${item.codename}">${item.codename}</option>
                            </c:if>

                        </c:forEach>
                    </select>
                    <input type="hidden" id="hidnation" value="${entity.nation}">
                </td>
                <td class="td_right">性别：</td>
                <td>
                    <c:if test="${entity.sex == 0||entity.sex==null}">
                        <input type="radio" name="sex" value="0" title="男" checked="">
                        <input type="radio" name="sex" value="1" title="女">
                    </c:if>
                    <c:if test="${entity.sex == 1}">
                        <input type="radio" name="sex" value="0" title="男">
                        <input type="radio" name="sex" value="1" title="女" checked="">
                    </c:if>

                    <input type="hidden" id="hidsex" value="${entity.sex}">
                </td>
            </tr>
            <tr>
                <td class="td_right">籍贯：</td>
                <td colspan="3">
                    <input type="text" name="userjg" autocomplete="off" class="layui-input" value="${entity.userjg}">
                </td>
            </tr>
            <tr>
                <td class="td_right">出生地：</td>
                <td colspan="3">
                    <input type="text" name="birthplace" autocomplete="off" class="layui-input"
                           value="${entity.birthplace}">
                </td>
            </tr>
            <tr>
                <td class="td_right">户籍地：</td>
                <td colspan="3">
                    <input type="text" name="domicileplace" autocomplete="off" class="layui-input"
                           value="${entity.domicileplace}">
                </td>
            </tr>
            <tr>
                <td class="td_right">出生日期：</td>
                <td>
                    <input type="text" id="birthday" name="birthday" lay-verify="required|date" autocomplete="off"
                           class="layui-input"
                           value="<fmt:formatDate value='${entity.birthday}' pattern='yyyy-MM-dd'/>">
                </td>
                <td class="td_right">身份证号：</td>
                <td>
                    <input type="text" name="cardno" lay-verify="required|identity" autocomplete="off"
                           class="layui-input" value="${entity.cardno}">
                </td>
            </tr>
            <tr>
                <td class="td_right">政治面貌：</td>
                <td>
                    <select name="zzmm" lay-verify="required">
                        <c:forEach var="item" items="${zzmmlst}">
                            <c:if test="${item.codename == entity.zzmm}">
                                <option selected="selected" value="${item.codename}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codename != entity.zzmm}">
                                <option value="${item.codename}">${item.codename}</option>
                            </c:if>
                        </c:forEach>
                    </select>
                </td>
                <td class="td_right">警号：</td>
                <td>
                    <input type="text" name="userno" autocomplete="off" class="layui-input" value="${entity.userno }">
                </td>
            </tr>

            <tr>
                <td class="td_right">参加公安工作时间：</td>
                <td>
                    <input type="text" id="cjgagzsj" name="cjgagzsj" lay-verify="required|date" autocomplete="off"
                           class="layui-input"
                           value="<fmt:formatDate value='${entity.cjgagzsj}' pattern='yyyy-MM-dd'/>">
                </td>
                <td class="td_right">参加工作时间：</td>
                <td>
                    <input type="text" id="cjgzsj" name="cjgzsj" lay-verify="required|date" autocomplete="off"
                           class="layui-input" value="<fmt:formatDate value='${entity.cjgzsj}' pattern='yyyy-MM-dd'/>">
                </td>
            </tr>

            <tr>
                <td class="td_right">学历：</td>
                <td>
                    <select name="qualifications" lay-verify="required">
                        <c:forEach var="item" items="${xllst}">
                            <c:if test="${item.codename == entity.qualifications}">
                                <option selected="selected" value="${item.codename}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codename != entity.qualifications}">
                                <option value="${item.codename}">${item.codename}</option>
                            </c:if>

                        </c:forEach>
                    </select>
                </td>
                <td class="td_right">学位：</td>
                <td>
                    <select name="degree" lay-verify="required">
                        <c:forEach var="item" items="${xwlst}">
                            <c:if test="${item.codename == entity.degree}">
                                <option selected="selected" value="${item.codename}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codename != entity.degree}">
                                <option value="${item.codename}">${item.codename}</option>
                            </c:if>

                        </c:forEach>
                    </select>
                </td>
            </tr>

            <tr>
                <td class="td_right">在职教育学历：</td>
                <td>
                    <select name="zzjyxl">
                        <option value="">请选择</option>
                        <c:forEach var="item" items="${xllst}">
                            <c:if test="${item.codename == entity.zzjyxl}">
                                <option selected="selected" value="${item.codename}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codename != entity.zzjyxl}">
                                <option value="${item.codename}">${item.codename}</option>
                            </c:if>

                        </c:forEach>
                    </select>
                </td>
                <td class="td_right">在职教育学位：</td>
                <td>
                    <select name="zzjyxw">
                        <option value="">请选择</option>
                        <c:forEach var="item" items="${xwlst}">
                            <c:if test="${item.codename == entity.zzjyxw}">
                                <option selected="selected" value="${item.codename}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codename != entity.zzjyxw}">
                                <option value="${item.codename}">${item.codename}</option>
                            </c:if>

                        </c:forEach>
                    </select>
                </td>
            </tr>


            <tr>
                <td class="td_right">职级：</td>
                <td>
                    <select name="rank" id="rank">
                        <c:forEach var="item" items="${rank}">
                            <c:if test="${item.codedes == entity.rank}">
                                <option selected="selected" value="${item.codedes}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codedes != entity.rank}">
                                <option value="${item.codedes}">${item.codename}</option>
                            </c:if>
                        </c:forEach>
                    </select>

                    <input type="hidden" id="hidrank" value="${entity.rank}">
                </td>
                <td class="td_right">入党时间：</td>
                <td>
                    <input type="text" id="joinpartytime" name="joinpartytime"
                           autocomplete="off" class="layui-input"
                           value="<fmt:formatDate value='${entity.joinpartytime}' pattern='yyyy-MM-dd'/>">

                </td>
            </tr>

            <tr>
                <td class="td_right">用户状态：</td>
                <td>
                    <select name="useryhzt">
                        <c:forEach var="item" items="${yhzt}">
                            <c:if test="${item.codename == entity.userstatus}">
                                <option selected="selected" value="${item.codename}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codename != entity.userstatus}">
                                <option value="${item.codename}">${item.codename}</option>
                            </c:if>
                        </c:forEach>
                    </select>
                </td>
            </tr>
            <tr>
                <td class="td_right">用户类型：</td>
                <td colspan="3">
                    <c:if test="${entity.usertype == 0||entity.usertype==null}">
                        <input type="radio" name="usertype" value="0" title="普通警员" checked="">
                        <input type="radio" name="usertype" value="1" title="部门领导">
                        <input type="radio" name="usertype" value="2" title="部门管理员">
                    </c:if>
                    <c:if test="${entity.usertype ==1}">
                        <input type="radio" name="usertype" value="0" title="普通警员">
                        <input type="radio" name="usertype" value="1" title="部门领导" checked="">
                        <input type="radio" name="usertype" value="2" title="部门管理员">
                    </c:if>
                    <c:if test="${entity.usertype ==2}">
                        <input type="radio" name="usertype" value="0" title="普通警员">
                        <input type="radio" name="usertype" value="1" title="部门领导">
                        <input type="radio" name="usertype" value="2" title="部门管理员" checked="">
                    </c:if>

                </td>

            </tr>

            <tr>
                <td class="td_right">首页：</td>
                <td colspan="3">
                    <c:if test="${entity.homeurl =='adminhome?id=0'}">
                        <input type="radio" name="homeurl" value="adminhome?id=0" title="管理员首页" checked="">
                        <input type="radio" name="homeurl" value="adminhome?id=1" title="领导首页">
                        <input type="radio" name="homeurl" value="normalhome" title="普通警员首页">
                    </c:if>
                    <c:if test="${entity.homeurl =='adminhome?id=1'}">
                        <input type="radio" name="homeurl" value="adminhome?id=0" title="管理员首页">
                        <input type="radio" name="homeurl" value="adminhome?id=1" title="领导首页" checked="">
                        <input type="radio" name="homeurl" value="normalhome" title="普通警员首页">
                    </c:if>
                    <c:if test="${entity.homeurl =='normalhome'||entity.homeurl==null}">
                        <input type="radio" name="homeurl" value="adminhome?id=0" title="管理员首页">
                        <input type="radio" name="homeurl" value="adminhome?id=1" title="领导首页">
                        <input type="radio" name="homeurl" value="normalhome" title="普通警员首页" checked="">
                    </c:if>
                </td>
            </tr>

            <tr>
                <td class="td_right">岗位：</td>
                <td>
                    <select name="usergw" lay-verify="required">
                        <c:forEach var="item" items="${usergw}">
                            <c:if test="${item.codename == entity.usergw}">
                                <option selected="selected" value="${item.codename}">${item.codename}</option>
                            </c:if>
                            <c:if test="${item.codename != entity.usergw}">
                                <option value="${item.codename}">${item.codename}</option>
                            </c:if>

                        </c:forEach>
                    </select>
                </td>
                <td style="text-align: center" colspan="2">
                    <button class="button" lay-submit="" lay-filter="demo1" id="btnsave">保存</button>
                    <input type="button" value="关闭" class="button" onclick="top.CloseOpenWindow()"/>
                </td>
            </tr>

        </table>

        <input type="hidden" name="userid" id="hiduserid" value="${entity.userid}">

    </form>
</div>
<script>


    layui.use(['form', 'element', 'laydate'], function () {
        var form = layui.form;
        var element = layui.element;
        var laydate = layui.laydate;
        laydate.render({
            elem: '#birthday'
        });
        laydate.render({
            elem: '#joinpartytime'
        });
        laydate.render({
            elem: '#cjgzsj'
        });
        laydate.render({
            elem: '#cjgagzsj'
        });
        form.render();


        //监听提交
        /*form.on('submit(demo1)', function(data){
          layer.alert(JSON.stringify(data.field), {
                   title: '最终的提交信息'
                 })
                 return false;
          }); */
    });

    function CloseDialog(result, msg) {
        top.frames["iframe"].vUser.addresult(result, msg);
    }
</script>
</body>
</html>